package com.linewow.xhyy.nihaonew.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.widget.ImageView;

import com.linewow.xhyy.nihaonew.R;
import com.linewow.xhyy.nihaonew.adapter.NihaoVPAdapter;
import com.linewow.xhyy.nihaonew.base.BaseFragmentActivity;
import com.linewow.xhyy.nihaonew.entity.user.Uinfo;
import com.linewow.xhyy.nihaonew.fragment.FanFragment;
import com.linewow.xhyy.nihaonew.fragment.FollowFragment;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by LXR on 2016/10/12.
 * 关注和粉丝界面
 */
public class FollowFanActivity extends BaseFragmentActivity {
    @Bind(R.id.toolbar_tab_tab)
    TabLayout toolbarTabTab;
    @Bind(R.id.toolbar_tab_left)
    ImageView toolbarTabLeft;
    @Bind(R.id.follow_fan_viewpager)
    ViewPager followFanViewpager;
    private NihaoVPAdapter adapter;
    private boolean flag;
    private FollowFragment followFragment;
    private FanFragment fanFragment;
    private String TAG="FollowFanActivity";
    private Uinfo uinfo;


    @Override
    public void initView() {
        super.initView();
        setContentView(R.layout.activity_follow_fan);
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {
        super.initData();
        flag=getIntent().getBooleanExtra("flag",false);
        NihaoVPAdapter vpAdapter=new NihaoVPAdapter(getSupportFragmentManager());
        followFragment=new FollowFragment();
        fanFragment=new FanFragment();
        Bundle bundle=getIntent().getExtras();
        if(bundle!=null){
            followFragment.setArguments(bundle);
            fanFragment.setArguments(bundle);
        }
        vpAdapter.addFragment(followFragment,getString(R.string.title_follow));
        vpAdapter.addFragment(fanFragment,getString(R.string.title_fan));
        followFanViewpager.setAdapter(vpAdapter);
        toolbarTabTab.setupWithViewPager(followFanViewpager);
        if(flag){
            followFanViewpager.setCurrentItem(1);
        }else{
            followFanViewpager.setCurrentItem(0);
        }

        if(bundle!=null){
            uinfo=bundle.getParcelable("info");
        }
        if(uinfo==null){
            vpAdapter.setFirstTitle(getString(R.string.title_follow_fan_mine)+" "+getString(R.string.title_follow));
            vpAdapter.setSecondTitle(getString(R.string.title_follow_fan_mine)+" "+getString(R.string.title_fan));
        }else{
            vpAdapter.setFirstTitle(getString(R.string.widget_mine_attention));
            vpAdapter.setSecondTitle(getString(R.string.widget_mine_fans));
        }


    }

    @Override
    public void initList() {
        super.initList();
    }


    @OnClick(R.id.toolbar_tab_left)
    public void onClick() {
        finish();
    }
}
